/****************************************************************************
**
** Copyright (C) 2009-2010 Mist Poryvaev.
** All rights reserved.
** Contact: Mist Poryvaev (mist.poryvaev@gmail.com)
**
** This file is part of the RailWorm project.
**
****************************************************************************/

#ifndef QUERYFORM_H
#define QUERYFORM_H

#include <QtGui>
#include <QtNetwork>
#include "htmlgenie.h"

namespace Ui {
    class QueryForm;
}

class SuggestCompletion;
class QueryForm : public QWidget {
	Q_OBJECT
public:
	~QueryForm();
	QString From();
	QString To();
	static QString Beautifulize(const QString & Text);
	static QueryForm * i();

private:
	HtmlGenie jinn;
	QueryForm(QWidget *parent = 0);
	Ui::QueryForm *m_ui;
	SuggestCompletion * m_Completer;
	QMap<int, QLineEdit *> m_Map;
	void Suggest(QString Text, QLineEdit * Edit);
	static QueryForm * g_Instance;

signals:
	void Query(const QString & From, const QString & To, const QString & DateStart, const QString & DateEnd);

private slots:
	void on_DateTimeEditEnd_dateTimeChanged(QDateTime date);
	void on_DateTimeEditStart_dateTimeChanged(QDateTime date);
	void on_pushButton_pressed();
	void on_SearchButton_pressed();
	void OnSuggestSrc(QString From);
	void OnSuggestDst(QString To);
	void OnSuggestPageFinished(HtmlResponse * Response, int Id, bool _Error);
};

#endif // QUERYFORM_H
